package com.flynn.rock.system.convert;

import com.flynn.rock.model.dto.system.AuthorityDto;
import com.flynn.rock.system.entity.SysAuthorityEntity;
import com.flynn.rock.system.entity.SysUserEntity;
import com.flynn.rock.system.model.vo.ListUserVo;
import com.flynn.rock.system.model.dto.SaveUserDto;
import com.flynn.rock.system.model.vo.UserDetailVo;
import com.flynn.rock.system.model.dto.SysUserDto;
import com.flynn.rock.system.model.request.SaveUserRequest;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class AbstractUserConvert {

    public static final AbstractUserConvert INSTANCE = Mappers.getMapper(AbstractUserConvert.class);

    public abstract SysUserEntity toSaveEntity(SaveUserRequest request);

    @Mapping(source = "realName", target = "nickName")
    public abstract SysUserEntity toSaveEntity(SaveUserDto userDto);

    @Mapping(target = "authorityStatus", source = "status")
    public abstract AuthorityDto toAuthorityDto(SysAuthorityEntity entity);

    public abstract SysUserDto toSysUserDto(SysUserEntity userEntity);

    public abstract ListUserVo toListUserVo(SysUserEntity userEntity);

    public abstract UserDetailVo toUserDetailVo(SysUserEntity userEntity);
}
